﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VivoPay : PayBase
{

	public enum PayType
	{
		/// 支付面板
		board = 0,
		/// 微信支付
		weixin = 1,
		/// 支付宝支付
		alipay = 2
	}

	public override void Init (params string[] key)
	{
		jo = new AndroidJavaObject ("com.vivopay.Main");
		jo.Call ("init", key [0], key [1], key [2]);
		jo.Call ("setCallBack", "TJSDK", "OnPayResult");
	}

	public override void Pay (string moneyAmount, string productName, string produceDesc, System.Action<bool> payCallBack)
	{
		jo.Call ("pay", moneyAmount, productName, produceDesc, (int)PayType.board);
		this.payCallBack = payCallBack;
	}

	public override void OnPayResult (string result)
	{
		if ("0" == result) {
			TJLog ("TJSDK---支付成功");
			if (payCallBack != null) {
				payCallBack (true);
			}
		} else if ("1" == result) {
			TJLog ("TJSDK---支付失败");
			if (payCallBack != null) {
				payCallBack (false);
			}
		}
	}

	public override void OnExitGame ()
	{
		jo.Call ("onExitGame");
	}
}
